package net.sxnic.ugr.group.action;

import java.util.HashSet;
import java.util.Map;

import net.sxnic.ugr.UgrActionSupport;
import net.sxnic.ugr.group.Group;
import net.sxnic.ugr.group.GroupManager;
import net.sxnic.ugr.role.Role;
import net.sxnic.ugr.role.util.RoleUtils;

import org.springframework.beans.factory.annotation.Autowired;


@SuppressWarnings("serial")
public class PreCreate extends UgrActionSupport {

	@Autowired
    private GroupManager groupManager;

    private Map<String, String> groupsInfo;
    
   	/**
   	 * 用户组所拥有的角色Html checkbox代码
   	 */
   	private String rolesHtml;
   	
	private Group group;
	
    public String execute() throws Exception {
		try {						
			 checkRoles(Role.SYSTEM_ADMIN);
		     group =new Group();
		    		     
		     rolesHtml = RoleUtils.createCheckboxHtml(new HashSet<Role>(),
						authorizationManager.getRoles(), "role");
		     			
		} catch (Exception e) {
			e.printStackTrace();
		}
       
        return SUCCESS;
    }


	public String getRolesHtml() {
		return rolesHtml;
	}

	public void setRolesHtml(String rolesHtml) {
		this.rolesHtml = rolesHtml;
	}


	/**
     * @return the groupsInfo
     */
    public Map<String, String> getGroupsInfo() {
        return groupsInfo;
    }


	public Group getGroup() {
		return group;
	}


	public void setGroup(Group group) {
		this.group = group;
	}


	public void setGroupsInfo(Map<String, String> groupsInfo) {
		this.groupsInfo = groupsInfo;
	}
}
